def check(mid:int):
    global n,m,k,suma,sumb
    l = min(mid,n,m)
    for i in range(l):
        if suma[l-i-1] + sumb[i] <= k : return True
    return False

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
suma = [a[0]]
for i in range(1,len(a)):
    suma.append(suma[i-1]+a[i])
sumb = [b[0]]
for i in range(1,len(b)):
    sumb.append(sumb[i-1]+b[i])
l = 0
r = n+m
while l+1<r:
    mid = (l+r)>>1
    if check(mid):
        l = mid + 1
    else:
        r = mid
print(r)
